package com.wc.alorithm_blue_bridge._数学知识.质数.Q8115;

import java.util.Scanner;

/**
 * @Author congege
 * @Description 克拉数
 * https://www.lanqiao.cn/problems/8115/learning/?page=1&first_category_id=1
 * @Date Created in 2023/12/19-18:06
 */
public class Main {
    static int maxN = (int) 1e5;
    static boolean[] isPrime = new boolean[maxN + 10];
    static int[] primes = new int[maxN + 10];
    static int idx = 0;

    static public void ola(int num) {
        isPrime[1] = true;
        for (int i = 2; i <= num; i++) {
            if (!isPrime[i]) {
                primes[++idx] = i;
            }
            for (int j = 1; i * primes[j] <= num; j++) {
                isPrime[primes[j] * i] = true;
                if (i % primes[j] == 0) {
                    break;
                }
            }
        }
    }

    public static void main(String[] args) {
        ola((int) 1e5);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        for (int i = n; i <= m; i++) {
            int num = i;
            while (num > 0) {
                if (!isPrime[num]) {
                    num /= 10;
                } else {
                    break;
                }
            }
            if (num == 0) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
